package beans;

import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import database.pack.DatabaseConnector;

public class StockReportBean implements Serializable
{
	private static final long serialVersionUID = 1L;
	private ArrayList<String> results = new ArrayList<String>();
	
	public ArrayList<String> getProduct()
	{
		try
		{
			DatabaseConnector databaseConnect = new DatabaseConnector();
			databaseConnect.connectToDatabase();
			Statement stat = databaseConnect.getConnection().createStatement();
			ResultSet res = stat.executeQuery("SELECT id,category,description,itemWeight,price,quantityInStock FROM product");
			
			while(res.next())
			{
				results.add(res.getString("id") + "/" + 
							res.getString("category") + "/" +
							res.getString("description") + "/" +
							res.getString("itemWeight") + "/" +
							res.getString("price") + "/" +
							res.getString("quantityInStock")
							); // Adding category and description results to the array
			}
			res.close();
			stat.close();
			databaseConnect.getConnection().close();
		}
		
		catch(SQLException | ClassNotFoundException e)
		{
			e.getMessage();
		}
		return results;
	}
	
	public ArrayList<String> getResults()
	{
		return results;
	}
}

